package com.yuanfengPlus.goodsManage.goodsManage.controller;

import com.yuanfengPlus.goodsManage.goodsManage.model.GoodsInfo;
import com.yuanfengPlus.goodsManage.goodsManage.service.GoodsInfoService;
import com.yuanfengPlus.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goodsInfo")
@Api(tags = "商品信息管理", description = "商品信息相关的API")
public class GoodsInfoController {

    @Autowired
    private GoodsInfoService goodsInfoService;

    @ApiOperation(value = "添加商品信息", notes = "添加一个新的商品信息")
    @PostMapping("/add")
    public Result addGoodsInfo(@RequestBody GoodsInfo goodsInfo) {
        return goodsInfoService.addGoodsInfo(goodsInfo);
    }

    @ApiOperation(value = "更新商品信息", notes = "更新现有的商品信息")
    @PutMapping("/update")
    public Result updateGoodsInfo(@RequestBody GoodsInfo goodsInfo) {
        return goodsInfoService.updateGoodsInfo(goodsInfo);
    }

    @ApiOperation(value = "更新商品品牌状态", notes = "更新商品品牌的状态")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "商品信息ID", required = true, dataType = "Integer", paramType = "query"),
        @ApiImplicitParam(name = "status", value = "状态", required = true, dataType = "String", paramType = "query")
    })
    @PutMapping("/updateBrandStatus")
    public Result updateGoodsBrandStatus(@RequestParam Integer id, @RequestParam String status) {
        return goodsInfoService.updateGoodsBrandStatus(id, status);
    }

    @ApiOperation(value = "查询所有商品信息", notes = "查询所有商品信息")
    @GetMapping("/query")
    public Result queryGoodsInfo() {
        return goodsInfoService.queryGoodsInfo();
    }

    @ApiOperation(value = "根据ID查询商品信息", notes = "根据ID查询商品信息")
    @ApiImplicitParam(name = "id", value = "商品信息ID", required = true, dataType = "Integer", paramType = "query")
    @GetMapping("/queryById")
    public Result queryGoodsInfoById(@RequestParam Integer id) {
        return goodsInfoService.queryGoodsInfoById(id);
    }
}
